import node_method
import sys
import const
import time

sys.path.append("../")


class StartNode(node_method.NodeMethod):
    def __init__(self, context):
        self.context = context

    def do(self):
        print("start new_node do")
        time.sleep(1)
        int_time = int(time.time())
        if int_time % 3 == 0:
            return const.NODE_FAIL
        elif int_time % 3 == 1:
            return const.NODE_SUCCESS
        else:
            return const.NODE_RETRY

    def retry(self):
        print("start new_node retry")
        time.sleep(1)
        int_time = int(time.time())
        if int_time % 3 == 0:
            return const.NODE_FAIL
        elif int_time % 3 == 1:
            return const.NODE_SUCCESS
        else:
            return const.NODE_RETRY


sys.modules['start'] = StartNode
